package cn.tedu.hospitalqd.controller;

import cn.tedu.hospitalqd.pojo.dto.RegistrationAddNewDTO;
import cn.tedu.hospitalqd.service.RegistrationService;
import cn.tedu.hospitalqd.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/registration")
@Api(tags = "10.预约挂号模块")
@Validated
public class RegistrationController {
    @Autowired
    private RegistrationService registrationService;
    @PostMapping("/add-new")
    @ApiOperation("添加")
    @ApiOperationSupport(order = 100)
    public JsonResult addNew(@Valid RegistrationAddNewDTO registrationAddNewDTO){
        log.debug("",registrationAddNewDTO);
        registrationService.addNew(registrationAddNewDTO);
        return JsonResult.ok();
    }
    @PostMapping("/{id:[0-9]+}/delete")
    @ApiOperation("删除")
    @ApiOperationSupport(order = 200)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id",value = "挂号ID",required = true,dataType = "long")
    })
    public JsonResult delete(@Range(min = 1,message = "删除失败,ID值无效")
                             @PathVariable Long id){
        registrationService.delete(id);
        return JsonResult.ok();
    }






}
